package com.mybatis.plus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatis.plus.entity.Post;
import com.mybatis.plus.dao.PostMapper;
import com.mybatis.plus.service.IPostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 岗位表 服务实现类
 * </p>
 *
 * @author wenbo
 * @since 2020-08-28
 */
@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements IPostService {

    @Override
    public Post selectOne() {
        QueryWrapper<Post> postQueryWrapper = new QueryWrapper<>();
        postQueryWrapper.eq("id", 6);
        Post post = baseMapper.selectOne(postQueryWrapper);
        return post;
    }

    /**
     * 分页测试
     *
     * @return
     */
    @Override
    public PageInfo<Post> selectPage() {
        PageHelper.startPage(1, 2);
        List<Post> posts = baseMapper.selectList(new QueryWrapper<Post>());
        return new PageInfo<>(posts);
    }
}
